home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / pvm34b3.zip / pvm34b3 / pvm3 / pvmgs / pvmgs_mac.h < prev    next >
C/C++ Source or Header  |  1997-07-22  |  4KB  |  114 lines

  1.  
  2. /* $Id: pvmgs_mac.h,v 1.6 1997/07/09 13:51:33 pvmsrc Exp $ */
  3.  
  4. /*
  5.  *         PVM version 3.4:  Parallel Virtual Machine System
  6.  *               University of Tennessee, Knoxville TN.
  7.  *           Oak Ridge National Laboratory, Oak Ridge TN.
  8.  *                   Emory University, Atlanta GA.
  9.  *      Authors:  J. J. Dongarra, G. E. Fagg, M. Fischer
  10.  *          G. A. Geist, J. A. Kohl, R. J. Manchek, P. Mucci,
  11.  *         P. M. Papadopoulos, S. L. Scott, and V. S. Sunderam
  12.  *                   (C) 1997 All Rights Reserved
  13.  *
  14.  *                              NOTICE
  15.  *
  16.  * Permission to use, copy, modify, and distribute this software and
  17.  * its documentation for any purpose and without fee is hereby granted
  18.  * provided that the above copyright notice appear in all copies and
  19.  * that both the copyright notice and this permission notice appear in
  20.  * supporting documentation.
  21.  *
  22.  * Neither the Institutions (Emory University, Oak Ridge National
  23.  * Laboratory, and University of Tennessee) nor the Authors make any
  24.  * representations about the suitability of this software for any
  25.  * purpose.  This software is provided ``as is'' without express or
  26.  * implied warranty.
  27.  *
  28.  * PVM version 3 was funded in part by the U.S. Department of Energy,
  29.  * the National Science Foundation and the State of Tennessee.
  30.  */
  31.  
  32. /* File: pvmgs_mac.h - various macros that are used throughout the   */
  33. /*     group server                                                  */
  34. /* Set the pvm_errno to info, print the error, and then return the   */
  35. /*     error                                                         */
  36. #define DO_ERROR_RTN( info, caller ) \
  37.     { pvm_errno = info; pvm_perror( caller ); return( info ); }
  38.  
  39. /* Allocate new memory for a string based if length > mxlen          */ 
  40. #define REALLOCSTRING( length, mxlen, name, caller ) \
  41.     { if ( (length) > (mxlen) ) \
  42.         { \
  43.             if ( name != (char *) NULL ) \
  44.                 PVM_FREE( name ); \
  45.             name = (char *) PVM_ALLOC( sizeof(char) * (length + 1), \
  46.                 caller ); \
  47.             mxlen = length; \
  48.         } \
  49.     }
  50.  
  51. /* Init a send buffer and pack the single integer result             */
  52. /* caller is used for error reporting                                */
  53. #define PK_IRESULT( result, caller) \
  54.     { if ( pvm_initsend( PvmDataDefault ) < 0 ) \
  55.         pvm_perror( caller ); \
  56.         if ( pvm_pkint( &(result), 1, 1 ) < 0 ) \
  57.             pvm_perror( caller ); \
  58.     }                              
  59.  
  60. /* Pack state. If state is STATIC then pack all group information.   */
  61. #define PK_STATE( tid, state, name, hash_list, ngroups, caller ) \
  62.     { if ( pvm_pkint( &(state), 1, 1 ) < 0 ) \
  63.         pvm_perror( caller ); \
  64.         if ( state == STATIC ) \
  65.             if ( gs_newstaticcache( tid, name, hash_list, ngroups, \
  66.                     caller ) == PvmgsNotCached ) \
  67.                 gs_pkstaticinfo( gs_group( name, hash_list, ngroups, \
  68.                         NOCREATE ) ); \
  69.     }
  70.  
  71. /* Send packed buffer to tid, msgtag. Caller used for err reporting  */
  72. #define SENDRESULT( tid, msgtag, caller ) \
  73.     if ( pvm_send( tid, msgtag ) < 0 ) \
  74.         pvm_perror( caller );                                 
  75.  
  76. /* Create a send buffer, pack a single integer, and send it          */
  77. #define SENDINTRESULT( result, tid, msgtag, caller ) \
  78.     { PK_IRESULT( result, caller ); SENDRESULT( tid, msgtag, caller ) }
  79.  
  80. /* Begin a trace event, keep track of the current trace level        */
  81. /* Optionally packs a single integer argument                        */
  82. #define BGN_TRACE( event, strarg, did, intarg ) \
  83.     if ( TEV_EXCLUSIVE ) { \
  84.         if (TEV_DO_TRACE( event, TEV_EVENT_ENTRY ) ) \
  85.         { \
  86.             TEV_PACK_STRING( TEV_DID_GN, TEV_DATA_SCALAR, \
  87.                 strarg ? strarg: "", 1, 1 ); \
  88.             if ( intarg != (int *) NULL ) \
  89.                 TEV_PACK_INT( did, TEV_DATA_SCALAR, intarg, 1, 1 ); \
  90.             TEV_FIN; \
  91.         } \
  92.     }
  93.  
  94. /* End trace event and send back an integer */
  95. #define END_TRACE( event, did, intarg ) \
  96.     if ( TEV_AMEXCL ) { \
  97.         if (TEV_DO_TRACE( event, TEV_EVENT_EXIT ) ) \
  98.         { \
  99.             TEV_PACK_INT( did, TEV_DATA_SCALAR, intarg, 1, 1 ); \
  100.             TEV_FIN; \
  101.         } \
  102.         TEV_ENDEXCL; \
  103.     }
  104.  
  105. /* Max, min. Interval confines the argument to the interval          */
  106. #ifndef MAX
  107. #define MAX(x,y) ((x) > (y) ? (x) : (y))                               
  108. #endif
  109. #ifndef MIN
  110. #define MIN(x,y) ((x) < (y) ? (x) : (y))                               
  111. #endif
  112. #define INTERVAL(x,a,y)  MIN(MAX((x),(a)), (y)) 
  113.  
  114.